package cn.le.poster;

import cn.le.poster.draw.PosterDefaultDraw;
import cn.le.poster.entity.SamplePoster;
import cn.le.poster.enums.EnumShape;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;

public class Test {

    public static void main(String[] args)throws Exception {

        String ce = Test.class.getClassLoader().getResource("ce.jpg").getPath();//获取文件路径
        String a200 = Test.class.getClassLoader().getResource("2258281_200.jpeg").getPath();//获取文件路径
        String a159 = Test.class.getClassLoader().getResource("159.png").getPath();//获取文件路径

        BufferedImage headImg = ImageIO.read(new File(ce));
        BufferedImage avatarImg = ImageIO.read(new File(a200));
        BufferedImage qr = ImageIO.read(new File(a159));


        SamplePoster samplePoster = SamplePoster.build()
                .canvas(670,1307, Color.WHITE)
                .img(670,900,headImg)
                .graphical(620,60,-30,30,new Color(0, 0, 0, 90),EnumShape.RoundedRectangle,50,100)
                .img(30,30,30,50,avatarImg, EnumShape.Circular)
                .img(150,150,450,1050,qr,EnumShape.None)
                .text("out of Memory  像你分享了一篇游行笔记",80,70,new Font("微软雅黑", Font.LAYOUT_NO_START_CONTEXT, 25),Color.white)
                .text("长按查看",480,1250,new Font("微软雅黑", Font.LAYOUT_NO_START_CONTEXT, 25),Color.lightGray)
                .text("875人觉得本文很精彩",30,1230,new Font("微软雅黑", Font.LAYOUT_NO_START_CONTEXT, 30),Color.lightGray)
                .graphical(100,60,0,1100,Color.YELLOW)
                .text("上市 | 旅行笔记",30,1150,new Font("微软雅黑", Font.CENTER_BASELINE, 35),Color.BLACK)
                .text("\"我叫小猪666\"的旅行笔记",30,950,new Font("微软雅黑", Font.LAYOUT_NO_LIMIT_CONTEXT, 30),Color.BLACK)
                .text("上海哪拍最出片 上海周末玩什么  上海美食探店",30,1000,new Font("微软雅黑", Font.LAYOUT_NO_START_CONTEXT, 25),Color.lightGray);

        BufferedImage image = PosterDefaultDraw.draw(samplePoster);
        ImageIO.write(image, "jpg", new File("/home/lansp/Pictures/bbb.jpg"));

        //圆角的透明矩形
        //RoundRectangle2D roundedRectangle = new RoundRectangle2D.Float(100, 100, 240, 160, 10, 10);
        //g2.draw(roundedRectangle);
    }

}
